; demopic.asm
; Image data for the demo

	.export bltdmpic

	.segment "RODATA"

; Bitmap data (RLE encoded for $FF)
demoimage:
	; column 0
	.byte $ff, $34, $b3, $7b, $1a, $6a, $6a, $92
	.byte $ff, $15, $fc, $fd, $fc, $ff, $01, $fe
	.byte $ff
	; column 1
	.byte $29, $f8, $fb, $fc, $fe, $fd, $f8, $ff
	.byte $09, $f8, $fa, $fa, $fa, $ff, $08, $2a
	.byte $aa, $aa, $20, $ff, $08, $fe, $fe, $ff
	.byte $09, $df, $fe, $da, $d6, $56, $56, $da
	.byte $ff
	; column 2
	.byte $29, $7f, $bf, $d3, $cd, $ad, $71, $ff
	.byte $07, $eb, $fb, $a9, $2b, $ab, $a9, $ff
	.byte $08, $d2, $98, $ba, $9a, $fe, $ff, $06
	.byte $47, $ff, $01, $54, $56, $56, $42, $7f
	.byte $ff, $06, $ef, $ec, $2b, $ac, $ae, $ac
	.byte $ff
	; column 3
	.byte $2b, $1c, $7b, $9b, $3c, $ff, $07, $7f
	.byte $7f, $25, $54, $5d, $65, $ff, $05, $bf
	.byte $9f, $bf, $a5, $b5, $b5, $b1, $bf, $ff
	.byte $08, $79, $f5, $f5, $f9, $fd, $f3, $ff
	.byte $06, $dd, $a9, $bb, $9b, $dd, $ff, $08
	.byte $c7, $d1, $d5, $d4, $ff
	; column 4
	.byte $1f, $88, $aa, $aa, $8a, $ff, $09, $62
	.byte $5a, $62, $3a, $eb, $f7, $ff, $06, $32
	.byte $6a, $b6, $d2, $3f, $ff, $08, $15, $75
	.byte $75, $30, $ff, $08, $52, $2a, $6e, $26
	.byte $b6, $ff, $08, $29, $a8, $ae, $89, $ff
	; column 5
	.byte $1f, $a1, $35, $b5, $b3, $f7, $ff, $06
	.byte $f9, $6d, $44, $b5, $95, $c4, $ff, $08
	.byte $bd, $3d, $bd, $9c, $ff, $09, $48, $5b
	.byte $5b, $c9, $ff, $07, $fd, $fd, $3d, $bd
	.byte $bd, $bd, $ff, $08, $97, $9f, $ef, $97
	.byte $f7, $ff
	; column 6
	.byte $03, $e2, $ea, $ea, $fa, $e4, $f6, $ff
	.byte $14, $f7, $52, $56, $56, $12, $ff, $07
	.byte $9f, $de, $44, $55, $55, $cc, $ff, $07
	.byte $fe, $5e, $46, $56, $52, $ff, $07, $3f
	.byte $bf, $22, $aa, $ae, $b6, $ff, $08, $9b
	.byte $51, $75, $37, $99, $ff, $06, $fe, $fe
	.byte $12, $b6, $b6, $b2, $ff
	; column 7
	.byte $04, $f3, $f7, $91, $b6, $b6, $90, $fd
	.byte $ff, $14, $44, $6d, $ed, $4d, $ff, $08
	.byte $bf, $8f, $af, $a5, $b5, $ff, $08, $38
	.byte $bd, $bd, $38, $fd, $ff, $06, $f9, $fb
	.byte $f8, $3b, $bb, $bc, $ff, $08, $1a, $53
	.byte $57, $56, $3b, $7f, $ff, $05, $7f, $7f
	.byte $c4, $b5, $b5, $40, $ff
	; column 8
	.byte $04, $bf, $bf, $15, $b5, $b5, $a1, $ff
	.byte $15, $59, $15, $55, $59, $ff, $06, $ef
	.byte $d1, $db, $fa, $f9, $cd, $e3, $ff, $08
	.byte $cc, $55, $55, $cc, $fd, $fd, $ff, $05
	.byte $fb, $ff, $01, $cb, $2b, $3b, $cb, $ff
	.byte $07, $fd, $9e, $5d, $5d, $5c, $de, $ff
	.byte $08, $8b, $a8, $ba, $8a, $ff
	; column 9
	.byte $06, $10, $55, $55, $50, $fd, $f3, $ff
	.byte $11, $e6, $ef, $aa, $6a, $6e, $22, $fb
	.byte $ff, $06, $f7, $27, $f3, $37, $b7, $37
	.byte $ff, $08, $46, $55, $55, $44, $df, $ff
	.byte $06, $bf, $cf, $e4, $d5, $d5, $ce, $ff
	.byte $08, $66, $55, $54, $57, $e6, $ff, $08
	.byte $e5, $f5, $f5, $e1, $ff
	; column 10
	.byte $04, $e4, $c5, $e5, $f5, $e5, $e0, $ff
	.byte $13, $7f, $ff, $01, $54, $c5, $d5, $54
	.byte $ff, $08, $bb, $55, $71, $75, $95, $ff
	.byte $08, $56, $45, $d5, $54, $ff, $07, $fe
	.byte $ff, $01, $47, $4e, $76, $4f, $ff, $08
	.byte $7b, $f6, $76, $76, $fb, $ff, $06, $f7
	.byte $f3, $7d, $16, $56, $59, $ff
	; column 11
	.byte $04, $97, $b7, $b4, $b5, $b5, $94, $ff
	.byte $13, $f7, $ff, $01, $76, $75, $f7, $74
	.byte $ff, $09, $35, $11, $d5, $3d, $fd, $f3
	.byte $ff, $06, $48, $d5, $d5, $c5, $ff, $08
	.byte $3f, $95, $55, $55, $31, $ff, $07, $ed
	.byte $65, $ad, $ad, $a5, $75, $ff, $08, $ea
	.byte $ea, $ea, $e1, $ff
	; column 12
	.byte $06, $47, $4f, $e7, $cf, $ff, $13, $df
	.byte $df, $4e, $de, $5e, $5e, $ff, $08, $ef
	.byte $dc, $c5, $f5, $cc, $ff, $06, $bf, $bf
	.byte $92, $aa, $ae, $a2, $ff, $09, $14, $46
	.byte $56, $52, $fe, $ff, $07, $97, $51, $35
	.byte $b5, $b6, $ff, $06, $fb, $fb, $89, $ab
	.byte $ab, $c9, $ff
	; column 13
	.byte $04, $1f, $4d, $48, $7a, $7a, $09, $ff
	.byte $13, $e7, $ff, $01, $a4, $2d, $ad, $a4
	.byte $ff, $07, $bf, $bf, $8a, $a8, $aa, $aa
	.byte $ff, $08, $b8, $3d, $bd, $bd, $ff, $07
	.byte $e7, $ef, $64, $ad, $ad, $64, $ff, $08
	.byte $e3, $b5, $b5, $e1, $f7, $f7, $ff, $05
	.byte $ef, $ef, $22, $6a, $6a, $2a, $fb, $ff
	; column 14
	.byte $03, $f9, $d9, $89, $ab, $ab, $99, $ff
	.byte $13, $bb, $bb, $89, $ab, $ab, $ab, $ef
	.byte $df, $ff, $06, $de, $a9, $ad, $ad, $cc
	.byte $fd, $ff, $05, $f2, $fe, $54, $16, $56
	.byte $52, $ff, $07, $fc, $fd, $45, $55, $55
	.byte $cd, $dd, $ff, $05, $7f, $f9, $6b, $5b
	.byte $5b, $5b, $6d, $ff, $08, $43, $eb, $eb
	.byte $4b, $ff
	; column 15
	.byte $06, $11, $55, $75, $25, $ff, $13, $ca
	.byte $df, $92, $da, $da, $d8, $df, $ff, $07
	.byte $fe, $44, $55, $55, $ce, $df, $ff, $07
	.byte $f2, $ef, $f1, $f2, $ff, $09, $8b, $a8
	.byte $ba, $9a, $ff, $08, $97, $51, $75, $75
	.byte $b5, $ff, $06, $bf, $df, $cc, $aa, $aa
	.byte $dc, $ff
	; column 16
	.byte $04, $f3, $b3, $32, $16, $d6, $32, $ff
	.byte $15, $8e, $bd, $bd, $9e, $ff, $01, $fc
	.byte $ff, $07, $57, $47, $d7, $d7, $ff, $06
	.byte $f5, $fd, $14, $55, $55, $35, $7f, $ff
	.byte $06, $f8, $fa, $fe, $fe, $fc, $be, $ff
	.byte $08, $97, $51, $75, $75, $b5, $ff, $06
	.byte $fe, $fe, $9e, $8e, $ee, $8e, $ff
	; column 17
	.byte $06, $44, $55, $cd, $64, $fd, $ff, $12
	.byte $fc, $fd, $65, $55, $5d, $65, $bd, $7f
	.byte $ff, $05, $7f, $9b, $55, $57, $57, $99
	.byte $ff, $08, $92, $d2, $96, $d2, $5f, $9f
	.byte $ff, $05, $3f, $9f, $d1, $d5, $d5, $39
	.byte $ff, $07, $df, $de, $c5, $d5, $d5, $d6
	.byte $ef, $df, $ff, $04, $e9, $ef, $29, $ab
	.byte $ab, $29, $ff
	; column 18
	.byte $05, $fd, $64, $55, $4d, $65, $ff, $13
	.byte $bf, $ff, $01, $2b, $a2, $aa, $ab, $ff
	.byte $01, $fe, $ff, $06, $bd, $1b, $78, $7e
	.byte $39, $ff, $08, $f2, $2f, $b1, $b3, $ff
	.byte $09, $3c, $1d, $dd, $3d, $ff, $08, $5e
	.byte $45, $54, $57, $56, $ff, $06, $f3, $f3
	.byte $76, $16, $56, $52, $ff
	; column 19
	.byte $04, $fd, $fd, $4d, $8d, $e7, $8d, $ff
	.byte $15, $22, $aa, $ae, $32, $9f, $3f, $ff
	.byte $06, $bb, $89, $ab, $ab, $9b, $bf, $ff
	.byte $07, $11, $55, $55, $19, $7f, $7f, $ff
	.byte $05, $f9, $fb, $aa, $aa, $aa, $88, $ff
	.byte $06, $f7, $ff, $01, $76, $f6, $76, $76
	.byte $f6, $ff, $06, $fe, $fe, $4e, $56, $d2
	.byte $5a, $ff
	; column 20
	.byte $1f, $47, $da, $da, $c6, $df, $df, $ff
	.byte $05, $3f, $fb, $22, $6a, $2a, $ab, $ff
	.byte $01, $fe, $ff, $04, $ef, $e7, $2c, $6a
	.byte $69, $6c, $ff, $07, $9f, $bf, $a8, $aa
	.byte $ab, $cc, $ff, $07, $fb, $fc, $3a, $ba
	.byte $b8, $bd, $ff, $06, $bc, $fd, $b4, $ad
	.byte $ad, $a5, $ff, $01, $fe
	; column 21
	.byte $ff, $1b, $ef, $ef, $48, $aa, $ab, $69
	.byte $ff, $08, $77, $aa, $ae, $ae, $36, $bf
	.byte $7f, $ff, $06, $af, $8f, $af, $ad, $f7
	.byte $ff, $08, $97, $b1, $b5, $94, $ff, $08
	.byte $cc, $ab, $a8, $ae, $cd, $ff, $06, $ef
	.byte $ef, $49, $6a, $6b, $69, $7f, $ff
	; column 22
	.byte $1e, $ae, $8f, $af, $ae, $ff, $08, $aa
	.byte $aa, $2a, $aa, $b4, $ff, $06, $c7, $f3
	.byte $db, $fa, $f9, $cb, $f7, $ff, $06, $fe
	.byte $fe, $92, $56, $36, $92, $ff, $08, $e1
	.byte $f5, $f5, $e5, $f3, $f7, $ff, $07, $bf
	.byte $8f, $af, $ab, $ff
	; column 23
	.byte $1f, $d5, $51, $55, $15, $ff, $08, $dd
	.byte $a9, $bb, $bb, $c9, $ff, $07, $ef, $27
	.byte $ef, $2f, $27, $ff, $07, $7f, $7f, $c5
	.byte $d4, $dd, $49, $ff, $07, $fe, $b2, $56
	.byte $56, $56, $b2, $ff
	; column 24
	.byte $29, $7f, $3f, $9f, $6f, $6f, $1f, $ff
	.byte $07, $3f, $7f, $3f, $7f, $6f, $2f, $ef
	.byte $ff, $05, $fb, $ff, $01, $7b, $1a, $5a
	.byte $4a, $ff, $0a, $7f, $7f, $7f, $ff, $07
	.byte $7b, $c9, $ab, $bb, $bb, $cd, $ff
	; column 25
	.byte $42, $df, $dd, $44, $d5, $d5, $55, $f7
	.byte $ef, $ff, $13, $3f, $7f, $1f, $df, $3f
	.byte $ff, $0C

	demosize = * - demoimage + 1
 
 	.segment "DATA"

bcounter:	.res 2
colcnt:		.res 1
 
	lines = 98
	blank = 14
 
	.segment "CODE"

; uncompress image to target bitmap (self-modifying code in pload & pstore!)
bltdmpic:	; A/X ... target bitmap
			sta pstore+1
			stx pstore+2
			lda #<demosize
			sta bcounter
			lda #>demosize
			sta bcounter+1
			lda #<demoimage
			sta pload+1
			lda #>demoimage
			sta pload+2
			lda #lines
			sta colcnt
@loop:		jsr pload
			bcs @end
			cmp #$FF
			bne @stsmp
			jsr pload
			bcs @end
			tax
@unroll:	lda #$FF
			jsr pstore
			dex
			bne @unroll
			beq @loop
@stsmp:		jsr pstore
			jmp @loop
@end:		rts

	.segment "DATA"

pload:		lda $A000
			inc pload+1
			bne @goon
			inc pload+2
@goon:		clc
			dec bcounter
			bne @fin
			ldx bcounter+1
			bne @decc
			sec
@decc:		dec bcounter+1
@fin:		rts
			
pstore:		sta $A000
			inc pstore+1
			bne @goon
			inc pstore+2
@goon:		dec colcnt
			bne @fin
			lda #lines
			sta colcnt
			clc
			lda pstore+1
			adc #blank
			sta pstore+1
			bcc @fin
			inc pstore+2
@fin:		rts


 